/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.mobiubiq.directory.client.frame.service;

import org.kalmeo.util.frame.Frame;
import org.mobiubiq.directory.client.data.Bookmark;
import org.mobiubiq.directory.client.data.BookmarksDataProvider;
import org.mobiubiq.directory.client.data.Service;
import org.mobiubiq.directory.client.frame.BookmarksEdit;

/**
 *
 * @author Marnix Renne
 */
public class ServiceFrameFactory {
    public static Frame getServiceFrame(Service service) {
        String url = service.getUrl();
        if(PlatformRequestServiceFrame.accepts(url)) {
            return new PlatformRequestServiceFrame(service);
        }
        if(url.startsWith(BookmarksEdit.PROTOCOL)) {
            return new BookmarksEdit(new BookmarksDataProvider(), new Bookmark(service.getObject()));
        }
        if(url.startsWith(AppServiceFrame.PROTOCOL)) {
            return new AppServiceFrame(service);
        }
        if(url.startsWith(LocationServiceFrame.PROTOCOL)) {
            return new LocationServiceFrame(service);
        }
        return new UnknownServiceTypeFrame(service);
    }
}
